package com.htjc.integral.conversion.inner.util;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.context.annotation.Configuration;

@Configuration
public class BeanUtil implements BeanFactoryAware{

	private static BeanFactory context;
	
	@Override
	public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
		context = beanFactory;
		System.out.println("==>>>>BeanFactory<<<<<<==");
	}

	public static Object getBean(String beanName){
		return context.getBean(beanName);
	}

	public static <T> T getBean(String beanName, Class<T> clazz){
		return context.getBean(beanName, clazz);
	}

	public static <T> T getBean(Class<T> clazz){
		return context.getBean(clazz);
	}
}
